<template>
  <div>
    <zh-card title="">
      <zh-form :model="pageData.queryParams" ref="queryFormRef">
        <zh-form-input prop="fieldId" label="字段主键" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldId"></zh-form-input>
        <zh-form-input prop="fieldName" label="接口字段名称   查询结果同名字段" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldName"></zh-form-input>
        <zh-form-input prop="fieldTypeId" label="接口类型id" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldTypeId"></zh-form-input>
        <zh-form-input prop="fieldType" label="接口字段类型 List Object 特殊处理" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldType"></zh-form-input>
        <zh-form-input prop="fieldAlias" label="接口字段别名   接口返回字段名称" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldAlias"></zh-form-input>
        <zh-form-input prop="fieldLocation" label="接口字段位置序号  入参查询位置" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.fieldLocation"></zh-form-input>
        <zh-form-input prop="subFieldTypeId" label="List Object 子类型主键" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.subFieldTypeId"></zh-form-input>
        <zh-form-select prop="fieldNullable" label="接口字段是否可为空" allowClear :span="8"
                        :options="pageData.dictData.OPTIONNULLABLE"
                        v-model="pageData.queryParams.fieldNullable"></zh-form-select>
        <zh-form-input prop="CREATENAME" label="创建人" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.CREATENAME"></zh-form-input>
        <zh-form-input prop="CREATETIME" label="创建时间" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.CREATETIME"></zh-form-input>
        <zh-form-input prop="UPDATETIME" label="更新时间" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.UPDATETIME"></zh-form-input>
        <zh-form-input prop="DEL" label="逻辑删除标志 0 正常 1 删除" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.DEL"></zh-form-input>
        <zh-form-input prop="UPDATENAME" label="修改人" type="text" :span="8" dataType="common"
                       v-model="pageData.queryParams.UPDATENAME"></zh-form-input>
        <zh-form-query @queryClick="queryDynamicLogicInterfaceType" :formRef="queryFormRef" :show-advanced="false">
          <el-button @click="showAddDialog">添加</el-button>
        </zh-form-query>
      </zh-form>
    </zh-card>
    <zh-table title="动态逻辑接口类型列表" ref="dynamicLogicInterfaceTypeTable"
              size="mini"
              :funcCode="'dynamicLogicInterfaceType0001'"
              :columns="pageData.tableColumns"
              highlight-current-row>
      <template #op="scope">
        <el-tooltip content="编辑" placement="top">
          <el-button :icon="Edit" link @click="showEditDialog(scope)"></el-button>
        </el-tooltip>
        <el-tooltip content="删除" placement="top">
          <el-button :icon="Delete" type="danger" link @click="delDynamicLogicInterfaceType(scope.row)"></el-button>
        </el-tooltip>
        <el-tooltip content="详情" placement="top">
          <el-button :icon="Document" link @click="showDetail(scope)"></el-button>
        </el-tooltip>
      </template>
    </zh-table>
    <el-dialog title="添加动态逻辑接口类型" v-model="pageData.addDynamicLogicInterfaceTypeDialogVisible">
      <zh-form :rules="pageData.formRules">
        <zh-form-input prop="fieldId" label="字段主键" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldId"></zh-form-input>
        <zh-form-input prop="fieldName" label="接口字段名称   查询结果同名字段" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldName"></zh-form-input>
        <zh-form-input prop="fieldTypeId" label="接口类型id" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldTypeId"></zh-form-input>
        <zh-form-input prop="fieldType" label="接口字段类型 List Object 特殊处理" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldType"></zh-form-input>
        <zh-form-input prop="fieldAlias" label="接口字段别名   接口返回字段名称" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldAlias"></zh-form-input>
        <zh-form-input prop="fieldLocation" label="接口字段位置序号  入参查询位置" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.fieldLocation"></zh-form-input>
        <zh-form-input prop="subFieldTypeId" label="List Object 子类型主键" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.subFieldTypeId"></zh-form-input>
        <zh-form-select prop="fieldNullable" label="接口字段是否可为空" allowClear :span="8"
                        :options="pageData.dictData.OPTIONNULLABLE"
                        v-model="pageData.formData.fieldNullable"></zh-form-select>
        <zh-form-input prop="CREATENAME" label="创建人" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.CREATENAME"></zh-form-input>
        <zh-form-input prop="CREATETIME" label="创建时间" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.CREATETIME"></zh-form-input>
        <zh-form-input prop="UPDATETIME" label="更新时间" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.UPDATETIME"></zh-form-input>
        <zh-form-input prop="DEL" label="逻辑删除标志 0 正常 1 删除" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.DEL"></zh-form-input>
        <zh-form-input prop="UPDATENAME" label="修改人" type="text" :span="8" dataType="common"
                       v-model="pageData.formData.UPDATENAME"></zh-form-input>
      </zh-form>
      <template #footer>
        <span class="dialog-footer">

          <el-button @click="pageData.addDynamicLogicInterfaceTypeDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="addDynamicLogicInterfaceType">
            保存
          </el-button>
        </span>
      </template>
    </el-dialog>
    <el-dialog title="修改动态逻辑接口类型" v-model="pageData.editDynamicLogicInterfaceTypeDialogVisible">
      <zh-form :rules="pageData.formRules">
        <zh-form-input prop="fieldId" label="字段主键"
                       v-model="pageData.editFormData.fieldId"></zh-form-input>
        <zh-form-input prop="fieldName" label="接口字段名称   查询结果同名字段"
                       v-model="pageData.editFormData.fieldName"></zh-form-input>
        <zh-form-input prop="fieldTypeId" label="接口类型id"
                       v-model="pageData.editFormData.fieldTypeId"></zh-form-input>
        <zh-form-input prop="fieldType" label="接口字段类型 List Object 特殊处理"
                       v-model="pageData.editFormData.fieldType"></zh-form-input>
        <zh-form-input prop="fieldAlias" label="接口字段别名   接口返回字段名称"
                       v-model="pageData.editFormData.fieldAlias"></zh-form-input>
        <zh-form-input prop="fieldLocation" label="接口字段位置序号  入参查询位置"
                       v-model="pageData.editFormData.fieldLocation"></zh-form-input>
        <zh-form-input prop="subFieldTypeId" label="List Object 子类型主键"
                       v-model="pageData.editFormData.subFieldTypeId"></zh-form-input>
        <zh-form-select prop="fieldNullable" label="接口字段是否可为空" allowClear :options="pageData.dictData.OPTIONNULLABLE"
                        v-model="pageData.editFormData.fieldNullable"></zh-form-select>
        <zh-form-input prop="CREATENAME" label="创建人"
                       v-model="pageData.editFormData.CREATENAME"></zh-form-input>
        <zh-form-input prop="CREATETIME" label="创建时间"
                       v-model="pageData.editFormData.CREATETIME"></zh-form-input>
        <zh-form-input prop="UPDATETIME" label="更新时间"
                       v-model="pageData.editFormData.UPDATETIME"></zh-form-input>
        <zh-form-input prop="DEL" label="逻辑删除标志 0 正常 1 删除"
                       v-model="pageData.editFormData.DEL"></zh-form-input>
        <zh-form-input prop="UPDATENAME" label="修改人"
                       v-model="pageData.editFormData.UPDATENAME"></zh-form-input>
      </zh-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="pageData.editDynamicLogicInterfaceTypeDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="editDynamicLogicInterfaceType">
            保存
          </el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script lang="ts" setup name="dynamicLogicInterfaceType">
import {Delete, Edit, Document} from '@element-plus/icons-vue'
import {ElMessageBox} from "element-plus";
// ------------------接收传入参数(组件)-------------------

// ------------------钩子函数----------------------------
// 初始化
onMounted(() => {
  init();
})

// ------------------定义子组件--------------------------
const dynamicLogicInterfaceTypeTable = ref();
const queryFormRef = ref();
// ------------------变量区------------------------------
const pageData = reactive({
  addDynamicLogicInterfaceTypeDialogVisible: false,
  editDynamicLogicInterfaceTypeDialogVisible: false,
  detailDialog: false,
  tableColumns: [
    {type: 'seq', width: 60, fixed: 'left', align: 'center', title: '序号'},
    {field: 'fieldId', title: '字段主键', visible: false, align: 'center', width: 100},
    {field: 'fieldName', title: '接口字段名称   查询结果同名字段', visible: true, align: 'center', width: 100},
    {field: 'fieldTypeId', title: '接口类型id', visible: true, align: 'center', width: 100},
    {field: 'fieldType', title: '接口字段类型 List Object 特殊处理', visible: true, align: 'center', width: 100},
    {field: 'fieldAlias', title: '接口字段别名   接口返回字段名称', visible: true, align: 'center', width: 100},
    {field: 'fieldLocation', title: '接口字段位置序号  入参查询位置', visible: true, align: 'center', width: 100},
    {field: 'subFieldTypeId', title: 'List Object 子类型主键', visible: true, align: 'center', width: 100},
    {field: 'fieldNullable', title: '接口字段是否可为空', visible: true, align: 'center', width: 100},
    {field: 'CREATENAME', title: '创建人', visible: false, align: 'center', width: 100},
    {field: 'CREATETIME', title: '创建时间', visible: false, align: 'center', width: 100},
    {field: 'UPDATETIME', title: '更新时间', visible: false, align: 'center', width: 100},
    {field: 'DEL', title: '逻辑删除标志 0 正常 1 删除', visible: false, align: 'center', width: 100},
    {field: 'UPDATENAME', title: '修改人', visible: false, align: 'center', width: 100},
    {field: 'op', title: '操作', visible: true, align: 'center', width: 100, fixed: 'right', slots: {default: 'op'}},
  ],
  queryParams: {
    fieldId: '',
    fieldName: '',
    fieldTypeId: '',
    fieldType: '',
    fieldAlias: '',
    fieldLocation: '',
    subFieldTypeId: '',
    fieldNullable: '',
    CREATENAME: '',
    CREATETIME: '',
    UPDATETIME: '',
    DEL: '',
    UPDATENAME: ''
  },
  formData: {
    fieldId: '',
    fieldName: '',
    fieldTypeId: '',
    fieldType: '',
    fieldAlias: '',
    fieldLocation: '',
    subFieldTypeId: '',
    fieldNullable: '',
    CREATENAME: '',
    CREATETIME: '',
    UPDATETIME: '',
    DEL: '',
    UPDATENAME: ''
  },
  editFormData: {
    fieldId: '',
    fieldName: '',
    fieldTypeId: '',
    fieldType: '',
    fieldAlias: '',
    fieldLocation: '',
    subFieldTypeId: '',
    fieldNullable: '',
    CREATENAME: '',
    CREATETIME: '',
    UPDATETIME: '',
    DEL: '',
    UPDATENAME: ''
  },
  formRules: {},
  dictFields: 'OPTIONNULLABLE,OPTIONNULLABLE',
  dictData: [],
});
// ------------------方法区------------------------------
const init = () => {
  getDict();
  queryDynamicLogicInterfaceType();
}
// 查询数据字典信息
const getDict = () => {
  let params = {
    dictFields: pageData.dictFields,
  };
  $api.common.getBatchDict.post(params).then((res: any) => {
    pageData.dictData = res.result;
  });
};
const queryDynamicLogicInterfaceType = () => {
  dynamicLogicInterfaceTypeTable.value.query(pageData.queryParams);
}
const showAddDialog = () => {
  pageData.addDynamicLogicInterfaceTypeDialogVisible = true;
  pageData.formData = {
    fieldId: '',
    fieldName: '',
    fieldTypeId: '',
    fieldType: '',
    fieldAlias: '',
    fieldLocation: '',
    subFieldTypeId: '',
    fieldNullable: '',
    CREATENAME: '',
    CREATETIME: '',
    UPDATETIME: '',
    DEL: '',
    UPDATENAME: ''
  }
}
const showEditDialog = (scope) => {
  pageData.editDynamicLogicInterfaceTypeDialogVisible = true;
  pageData.editFormData = {...scope.row}
}
const addDynamicLogicInterfaceType = () => {
  $api.common.send.post('dynamicLogicInterfaceType0004', pageData.formData).then(res => {
    if (res.code == 0) {
      ElMessageBox.alert('添加动态逻辑接口类型成功');
      pageData.addDynamicLogicInterfaceTypeDialogVisible = false;
      queryDynamicLogicInterfaceType();
    }
  })
}
const editDynamicLogicInterfaceType = () => {
  $api.common.send.post('dynamicLogicInterfaceType0005', pageData.editFormData).then(res => {
    if (res.code == 0) {
      ElMessageBox.alert('修改动态逻辑接口类型成功');
      pageData.editDynamicLogicInterfaceTypeDialogVisible = false;
      queryDynamicLogicInterfaceType();
    }
  })
}
const delDynamicLogicInterfaceType = ({fieldId}) => {
  ElMessageBox.confirm('确定删除该动态逻辑接口类型?').then(() => {
    $api.common.send.post('dynamicLogicInterfaceType0006', {fieldId: fieldId}).then(res => {
      if (res.code == 0) {
        ElMessageBox.alert('删除动态逻辑接口类型成功');
        queryDynamicLogicInterfaceType();
      }
    })
  })
}

</script>
<style lang="scss" scoped></style>
